#include <vector>
#include <iostream>
#include "basic_cpp.hpp"
#include "matrix_operations.hpp"

using namespace std;

float * findProduct(MatrixOperations matrix, MatrixOperations v, int nrTimes) {
	clock_t init, final;

	int rows = matrix.getNumRows();
	int columns = matrix.getNumCols();
	float * mValues = matrix.getMatrix();
	float * vValues = v.getMatrix();


	float * answer = new float[rows];

	init=clock();
	for(int i = 0; i < nrTimes; i++) {
		for(int i = 0; i < rows ; i++) {
			answer[i] = 0;
			int rowStart = i*columns;
			for(int j = 0; j < columns  ; j++) {
				answer[i] = answer[i] + mValues[rowStart+j] * vValues[j];
			}
		}
	}

	final=clock()-init;
	double time = (double)final / ((double)CLOCKS_PER_SEC);
	cout << "Calculation took: " << time << " seconds. (C++ loop)" << endl;
	cout << "basic cpp, time per: " << time/nrTimes << endl;
	return answer;
}
